package com.example.vspm.util;

import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Date;

/**
 * @author LCL
 * @date 2022/4/8
 * @desc
 */
public class TimeStampUtil {
    public  Timestamp tm(String time){
        System.out.println(time+"  前台传过来的时间");
        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        LocalDateTime localDateTime = LocalDateTime.parse(time.replaceAll("T", " ") + ":00", df);
        System.out.println(localDateTime+"   localDateTime格式的时间");
        Date date = Date.from( localDateTime.atZone( ZoneId.systemDefault()).toInstant());
        System.out.println(date+"  Date格式的时间（java.util的包）");
        Timestamp timestamp = new Timestamp(date.getTime());
        System.out.println(timestamp+"  Timestamp格式的时间（java.sql的包）");
        return timestamp ;
    }

}
